package landlords.server;

import landlords.entity.ClientSide;
import landlords.entity.Room;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.atomic.AtomicInteger;

public class ServerContains {
    public static int port=1024;

    public final static Map<String,Integer> CHANNEL_ID_MAP= new ConcurrentHashMap<>();
    public final static Map<Integer,ClientSide> CLIENT_SIDE_MAP=new ConcurrentSkipListMap<>();
    private final static Map<Integer, Room> ROOM_MAP=new ConcurrentSkipListMap<>();

    private final static AtomicInteger CLIENT_ATOMIC_ID=new AtomicInteger(1);
    private final static AtomicInteger SERVER_ATOMIC_ID=new AtomicInteger(1);

    public final static int getClientId(){
        return CLIENT_ATOMIC_ID.getAndIncrement();
    }
    public final static int getServerId(){
        return SERVER_ATOMIC_ID.getAndIncrement();
    }
    public static Room getRoom(int id){
        Room room=ROOM_MAP.get(id);
        return room;
    }
    //暂时禁用
    //public static Room addRoom(Room room){
        //return ROOM_MAP.put(room.getId(), room);
    //}
}
